package cn.damai.controller.web;

import cn.damai.content.model.ItemDTO;
import cn.damai.content.service.DetailService;
import cn.damai.model.SchedulerSeatPrice;
import cn.damai.util.DubboUtil;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 详情控制层
 */
@Controller
@RequestMapping("detail")
public class DetailController {

    @Reference(url = DubboUtil.CONTENT_URL,version = DubboUtil.VRESION,group = DubboUtil.GROUP)
    private DetailService detailService;

//    测试区域start
    @RequestMapping("test")
    public String toTest(){
        return "test/detailTest";
    }
//    测试区域end


//    开发区域

//      根据商品ID查询详情
    @GetMapping("content")
    public String content(@RequestParam("itemId")Long itemId, Model model){
        ItemDTO itemDTO = detailService.queryInfoByItemId(itemId);
        model.addAttribute("itemDTO",itemDTO);
        return "details";
    }
//      通过ajax更不同新场次价格
    @GetMapping("queryPrice/{scheduleId}")
    @ResponseBody
    public List<SchedulerSeatPrice> queryPrice(@PathVariable("scheduleId")Long scheduleId){
        List<SchedulerSeatPrice> schedulerSeatPrices = detailService.queryPrice(scheduleId);
        return schedulerSeatPrices;
    }



}
